﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZRFCore.Tool;

namespace MultiAxisVisionAssembly
{
    [Serializable]
    public class SysParameter
    {
        public double ZWorkPos { get; set; }//Z轴与板面接触的Z轴高度位置
        public double ZSafePos { get; set; }//Z轴安全高度位
        public double ZSmallWorkPos { get; set; }//点胶头伸出来时与板面接触高度
        /// <summary>
        /// 读取系统参数
        /// </summary>
        public void ReadSysParameter()
        {
            SysParameter? _sysParameter = ParameterHelper.GetParamFromFile<SysParameter>(Directory.GetCurrentDirectory() + "/SysParameter.xml");
            if (_sysParameter == null)
            {
                _sysParameter = new SysParameter();
                _sysParameter.ZWorkPos = 57;
                _sysParameter.ZSmallWorkPos = 38.781;
                _sysParameter.ZSafePos = 0;

            }
            ZWorkPos = _sysParameter.ZWorkPos;
            ZSmallWorkPos = _sysParameter.ZSmallWorkPos;
            ZSafePos = _sysParameter.ZSafePos;
        }

        /// <summary>
        /// 保存系统参数
        /// </summary>
        public void SaveSysParameter()
        {
            ParameterHelper.SaveParam(this, Directory.GetCurrentDirectory() + "/SysParameter.xml");
        }
    }
}
